package com.gsn.poker.asset;

import java.util.List;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver;
import com.badlogic.gdx.assets.loaders.resolvers.ResolutionFileResolver;
import com.badlogic.gdx.assets.loaders.resolvers.ResolutionFileResolver.Resolution;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.ParticleEffect;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.gsn.engine.gdx.GsnParticleActor;
import com.gsn.engine.gdx.assets.GsnManagerTexture;

public class PokerTexture extends GsnManagerTexture {

	public static PokerTexture _instance;

	public static PokerTexture inst() {
		if (_instance == null)
			_instance = new PokerTexture();
		return _instance;
	}

	// public AssetManager manager;

	public ParticleEffect clickEff;
	public ParticleEffect jackpotEff;
	public List<AtlasRegion> start;
	public List<AtlasRegion> labai;
	public List<AtlasRegion> Time;
	public List<AtlasRegion> bubbleChatPhai;
	public List<AtlasRegion> bubbleChatTrai;
	public List<AtlasRegion> chip;
	public List<AtlasRegion> cong;
	public List<AtlasRegion> tru;

	public AtlasRegion emo1;
	public AtlasRegion emo2;
	public AtlasRegion emo3;
	public AtlasRegion emo4;
	public AtlasRegion emo5;
	public AtlasRegion emo6;
	public AtlasRegion emo7;
	public AtlasRegion emo8;
	public AtlasRegion emo9;
	public AtlasRegion emo10;
	public AtlasRegion emo11;
	public AtlasRegion emo12;
	public AtlasRegion emo13;
	public AtlasRegion emo14;
	public AtlasRegion emo15;
	public AtlasRegion emo16;
	public AtlasRegion emo17;
	public AtlasRegion emo18;
	public AtlasRegion emo19;
	public AtlasRegion emo20;

	public BitmapFont fontMedium;
	public BitmapFont fontLarge;
	public BitmapFont fontSmall;

	static public final String tag = "Poker Texture";

	// static public List<AtlasRegion> timeCho;
	public AtlasRegion arrow;
	public AtlasRegion dotWait;
	public AtlasRegion dotWatch;
	public AtlasRegion board;
	public AtlasRegion chuThang;
	public AtlasRegion chuThua;
	public AtlasRegion iconHost;
	public AtlasRegion joinBtn;
	public AtlasRegion joinBtnDown;
	public AtlasRegion nenJackpot;
	public AtlasRegion nenThang;
	public AtlasRegion nenThua;
	public AtlasRegion selectCardBG;
	public AtlasRegion timeMobai;
	public AtlasRegion timeMobaiDown;
	public AtlasRegion viewBtn;

	public AtlasRegion xoayThungPhaSanh;

	public AtlasRegion baiUp;
	public AtlasRegion BgAlpha;
	public AtlasRegion iconUSDcuoc;

	public AtlasRegion thangXiTo;
	public AtlasRegion daucong;
	public AtlasRegion dautru;
	public AtlasRegion dauphaycong;
	public AtlasRegion dauphaytru;

	public AtlasRegion upboBtn;
	public AtlasRegion upboBtnDown;
	public AtlasRegion nhuongToBtn;
	public AtlasRegion nhuongToBtnDown;
	public AtlasRegion theoBtn;
	public AtlasRegion theoBtnDown;
	public AtlasRegion toBtn;
	public AtlasRegion toBtnDown;
	public AtlasRegion toGapDoiBtn;
	public AtlasRegion toGapDoiBtnDown;
	public AtlasRegion toMotPhanTuBtn;
	public AtlasRegion toMotPhanTuBtnDown;
	public AtlasRegion toNuaBtn;
	public AtlasRegion toNuaBtnDown;
	public AtlasRegion toTatCaBtn;
	public AtlasRegion toTatCaBtnDown;

	public AtlasRegion upboBtnDisable;

	public AtlasRegion nhuongToBtnDisable;

	public AtlasRegion theoBtnDisable;

	public AtlasRegion toBtnDisable;

	public AtlasRegion toGapDoiBtnDisable;

	public AtlasRegion toMotPhanTuBtnDisable;

	public AtlasRegion toNuaBtnDisable;

	public AtlasRegion toTatCaBtnDisable;

	public AtlasRegion quitBtn;
	public AtlasRegion quitBtnDown;
	public AtlasRegion chatBtn;
	public AtlasRegion chatBtnDown;
	public AtlasRegion soundBtn;
	public AtlasRegion soundBtnDown;
	public AtlasRegion soundBtnOff;
	public AtlasRegion logoXito;
	public AtlasRegion avatarBG;
	public AtlasRegion cancelBtn;
	public AtlasRegion cancelBtnDown;
	public AtlasRegion okBtn;
	public AtlasRegion okBtnDown;
	public AtlasRegion dialogBg;
	public AtlasRegion jackpot;

	public AtlasRegion chuCulu;
	public AtlasRegion chuDoi;
	public AtlasRegion chuMau;
	public AtlasRegion chuSamCo;
	public AtlasRegion chuSanh;
	public AtlasRegion chuTheo;
	public AtlasRegion chuThu;
	public AtlasRegion chuThung;
	public AtlasRegion chuThungPhaSanh;
	public AtlasRegion chuTo;
	public AtlasRegion chuToGapDoi;
	public AtlasRegion chuToMotNua;
	public AtlasRegion chuToMotPhanTu;
	public AtlasRegion chuChoiToiBen;
	public AtlasRegion chuToTatCa;
	public AtlasRegion chuTuQuy;
	public AtlasRegion chuUpBo;
	public AtlasRegion chuNhuongTo;

	public AtlasRegion chuChoNguoiKhac;

	public AtlasRegion startBtn;
	public AtlasRegion startBtnDown;

	public AtlasRegion nenNangCao;
	public AtlasRegion nenTapSu;
	public AtlasRegion selectCard;
	public AtlasRegion bgBet;
	public AtlasRegion bgAvatar;
	public AtlasRegion betSum;
	public AtlasRegion viewing;
	public AtlasRegion afterTime;
	public AtlasRegion chuThungPhaSanhEffect;

	public Skin skin;

	/*
	 * public void assignContent(PokerTexture obj) { if (!onceAssign) return;
	 * 
	 * clickEff = GsnParticleActor.loadParticleEffect(resolver,
	 * "poker/particle/click.p");
	 * 
	 * TextureAtlas atlas = manager.get("poker/content/pack",
	 * TextureAtlas.class); fontMedium = manager.get("poker/font/medium.fnt",
	 * BitmapFont.class); fontLarge = manager.get("poker/font/large.fnt",
	 * BitmapFont.class); // board = atlas.findRegion("BG1");
	 * 
	 * Field[] fields = PokerTexture.class.getFields(); for (int i = 0; i <
	 * fields.length; i++) { Field f = fields[i]; if
	 * (Modifier.isPublic(f.getModifiers()) &&
	 * Modifier.isStatic(f.getModifiers())) { try { if (f.get(obj) != null)
	 * continue; if (f.getType() == AtlasRegion.class) { AtlasRegion region =
	 * atlas.findRegion(f.getName()); f.set(obj, region); if (region == null) {
	 * Gdx.app.log(tag, "region = null voi : " + f.getName()); } }
	 * 
	 * if (f.getType() == List.class) { List<AtlasRegion> region =
	 * atlas.findRegions(f.getName()); f.set(obj, region); if (region == null) {
	 * Gdx.app.log(tag, "List<region> = null voi : " + f.getName()); } } } catch
	 * (Exception e) { e.printStackTrace(); } } } onceAssign = false; }
	 */

	@Override
	public void assignTask() {
		//clickEff = GsnParticleActor.loadParticleEffect(resolver, "poker/particle/click.p");
		clickEff = manager.get("poker/particle/click.p", ParticleEffect.class);
		
		jackpotEff = GsnParticleActor.loadParticleEffect(resolver, "poker/particle/jackpot.p");
		fontMedium = manager.get("poker/font/medium.fnt", BitmapFont.class);
		fontLarge = manager.get("poker/font/large.fnt", BitmapFont.class);
		fontSmall = manager.get("poker/font/small.fnt", BitmapFont.class);

		TextureAtlas atlas = manager.get("poker/content/pack", TextureAtlas.class);
		autoAssignAtlas(atlas);

		//
		// countStart = atlas.findRegions("start");
		// labai = atlas.findRegions("labai");
		// Time = atlas.findRegions("Time");
		// vien = atlas.findRegions("vien");
		// bubbleChatPhai = atlas.findRegions("bubbleChatPhai");
		// bubbleChatTrai = atlas.findRegions("bubbleChatTrai");
		// chip = atlas.findRegions("chip");
		// cong = atlas.findRegions("cong");
		// tru = atlas.findRegions("tru");
		//
		// dotWait = atlas.findRegion("dotWait");
		// dotWatch = atlas.findRegion("dotWatch");
		// board = atlas.findRegion("board");
		// chuThang = atlas.findRegion("chuThang");
		// chuThua = atlas.findRegion("chuThua");
		// iconHost = atlas.findRegion("iconHost");
		// joinBtn = atlas.findRegion("joinBtn");
		// joinBtnDown = atlas.findRegion("joinBtnDown");
		// nenJackpot = atlas.findRegion("nenJackpot");
		// jackpot = atlas.findRegion("jackpot");
		// nenThang = atlas.findRegion("nenThang");
		// nenThua = atlas.findRegion("nenThua");
		// selectCardBG = atlas.findRegion("selectCardBG");
		// timeMobai = atlas.findRegion("timeMobai");
		// timeMobaiDown = atlas.findRegion("timeMobaiDown");
		// viewBtn = atlas.findRegion("viewBtn");
		//
		// xoayThungPhaSanh = atlas.findRegion("xoayThungPhaSanh");
		//
		// // closeViewerBtnDown = atlas.findRegion("closeViewerBtnDown");
		// // closeViewerBtn = atlas.findRegion("closeViewerBtn");
		//
		// baiUp = atlas.findRegion("baiUp");
		// BgAlpha = atlas.findRegion("BgAlpha");
		// iconUSDcuoc = atlas.findRegion("iconUSDcuoc");
		//
		// thangXiTo = atlas.findRegion("thangXiTo");
		// daucong = atlas.findRegion("daucong");
		// dautru = atlas.findRegion("dautru");
		// dauphaycong = atlas.findRegion("dauphaycong");
		// dauphaytru = atlas.findRegion("dauphaytru");
		//
		// upboBtn = atlas.findRegion("upboBtn");
		// upboBtnDown = atlas.findRegion("upboBtnDown");
		// nhuongtoBtn = atlas.findRegion("nhuongToBtn");
		// nhuongtoBtnDown = atlas.findRegion("nhuongToBtnDown");
		// theoBtn = atlas.findRegion("theoBtn");
		// theoBtnDown = atlas.findRegion("theoBtnDown");
		// toBtn = atlas.findRegion("toBtn");
		// toBtnDown = atlas.findRegion("toBtnDown");
		// toGapDoiBtn = atlas.findRegion("toGapDoiBtn");
		// toGapDoiBtnDown = atlas.findRegion("toGapDoiBtnDown");
		// toMotPhanTuBtn = atlas.findRegion("toMotPhanTuBtn");
		// toMotPhanTuBtnDown = atlas.findRegion("toMotPhanTuBtnDown");
		// toNuaBtn = atlas.findRegion("toNuaBtn");
		// toNuaBtnDown = atlas.findRegion("toNuaBtnDown");
		// toTatCaBtn = atlas.findRegion("toTatCaBtn");
		// toTatCaBtnDown = atlas.findRegion("toTatCaBtnDown");
		//
		// upboBtnDisable = atlas.findRegion("upboBtnDisable");
		//
		// nhuongtoBtnDisable = atlas.findRegion("nhuongToBtnDisable");
		//
		// theoBtnDisable = atlas.findRegion("theoBtnDisable");
		//
		// toBtnDisable = atlas.findRegion("toBtnDisable");
		//
		// toGapDoiBtnDisable = atlas.findRegion("toGapDoiBtnDisable");
		//
		// toMotPhanTuBtnDisable = atlas.findRegion("toMotPhanTuBtnDisable");
		//
		// toNuaBtnDisable = atlas.findRegion("toNuaBtnDisable");
		//
		// toTatCaBtnDisable = atlas.findRegion("toTatCaBtnDisable");
		//
		// quitBtn = atlas.findRegion("quitBtn");
		// quitBtnDown = atlas.findRegion("quitBtnDown");
		// chatBtn = atlas.findRegion("chatBtn");
		// chatBtnDown = atlas.findRegion("chatBtnDown");
		// soundBtn = atlas.findRegion("soundBtn");
		// soundBtnDown = atlas.findRegion("soundBtnDown");
		// soundBtnOff = atlas.findRegion("soundBtnOff");
		// logoXito = atlas.findRegion("logoXito");
		// avatarBG = atlas.findRegion("avatarBG");
		// cancelBtn = atlas.findRegion("cancelBtn");
		// cancelBtnDown = atlas.findRegion("cancelBtnDown");
		// okBtn = atlas.findRegion("okBtn");
		// okBtnDown = atlas.findRegion("okBtnDown");
		// dialogBg = atlas.findRegion("dialogBg");
		//
		// chuCulu = atlas.findRegion("chuCulu");
		// chuDoi = atlas.findRegion("chuDoi");
		// chuMau = atlas.findRegion("chuMau");
		// chuSamCo = atlas.findRegion("chuSamCo");
		// chuSanh = atlas.findRegion("chuSanh");
		// chuTheo = atlas.findRegion("chuTheo");
		// chuThu = atlas.findRegion("chuThu");
		// chuThung = atlas.findRegion("chuThung");
		// chuThungPhaSanh = atlas.findRegion("chuThungPhaSanh");
		// chuTo = atlas.findRegion("chuTo");
		// chuToGapDoi = atlas.findRegion("chuToGapDoi");
		// chuToMotNua = atlas.findRegion("chuToMotNua");
		// chuToMotPhanTu = atlas.findRegion("chuToMotPhanTu");
		// chuToTatCa = atlas.findRegion("chuToTatCa");
		// chuTuQuy = atlas.findRegion("chuTuQuy");
		// chuUpBo = atlas.findRegion("chuUpBo");
		// chuNhuongTo = atlas.findRegion("chuNhuongTo");
		//
		// chuChoNguoiKhac = atlas.findRegion("chuChoNguoiKhac");
		//
		// startBtn = atlas.findRegion("startBtn");
		// startBtnDown = atlas.findRegion("startBtnDown");
		//
		// nenNangCao = atlas.findRegion("nenNangCao");
		// nenTapSu = atlas.findRegion("nenTapSu");
		// selectCard = atlas.findRegion("selectCard");
		// bgBet = atlas.findRegion("nen muc cuoc");
		// bgAvatar = atlas.findRegion("khung hien thi");
		// betSum = atlas.findRegion("bang tien cuoc");
		// viewing = atlas.findRegion("viewing");
		// arrow = atlas.findRegion("mui ten nan bai");
		// afterTime = atlas.findRegion("van dau bat dau sau");
		// thungPhaSanhEffect = atlas.findRegion("chuThungPhaSanhEffect");
		// chuChoiToiBen = atlas.findRegion("chuChoiToiBen");
		//
		//
		// emo1 = atlas.findRegion("Emo1");
		// emo2 = atlas.findRegion("Emo2");
		// emo3 = atlas.findRegion("Emo3");
		// emo4 = atlas.findRegion("Emo4");
		// emo5 = atlas.findRegion("Emo5");
		// emo6 = atlas.findRegion("Emo6");
		// emo7 = atlas.findRegion("Emo7");
		// emo8 = atlas.findRegion("Emo8");
		// emo9 = atlas.findRegion("Emo9");
		// emo10 = atlas.findRegion("Emo10");
		// emo11 = atlas.findRegion("Emo11");
		// emo12 = atlas.findRegion("Emo12");
		// emo13 = atlas.findRegion("Emo13");
		// emo14 = atlas.findRegion("Emo14");
		// emo15 = atlas.findRegion("Emo15");
		// emo16 = atlas.findRegion("Emo16");
		// emo17 = atlas.findRegion("Emo17");
		// emo18 = atlas.findRegion("Emo18");
		// emo19 = atlas.findRegion("Emo19");
		// emo20 = atlas.findRegion("Emo20");
		Gdx.app.log(tag, " DA FINISH ");
	}

	// board = atlas.findRegion("BG1")
	public void loadTexture() {
		manager.load("poker/content/pack", TextureAtlas.class);
		manager.load("poker/font/medium.fnt", BitmapFont.class);
		manager.load("poker/font/large.fnt", BitmapFont.class);
		manager.load("poker/font/small.fnt", BitmapFont.class);
		
		manager.load("poker/particle/click.p", ParticleEffect.class);
	}

	public void create() {
		Resolution[] resolutions = { new Resolution(240, 320, "240320"), new Resolution(480, 800, "480800") };
		resolver = new ResolutionFileResolver(new InternalFileHandleResolver(), resolutions);
		manager = new AssetManager(resolver);
		// manager.setErrorListener(new AssetErrorListener() {
		// @Override
		// public void error(String fileName, Class type, Throwable throwable) {
		// // TODO Auto-generated method stub
		// Gdx.app.error(tag, "couldn't load asset '" + fileName + "'",
		// (Exception) throwable);
		// }
		// });
		// Texture.setAssetManager(manager);
	}

}
